home *** CD-ROM | disk | FTP | other *** search
/ MacWorld Secrets (4th Edition) / Mac Secrets CD 4th Ed.toast / Apple Advanced Technologies / Apple Speech Technologies 1.5 / PlainTalk Developer Info / Speech Recognition Manager SDK / SR Sample Code / IM SR Example / MyHandleSpeechDetected.c < prev    next >
C/C++ Source or Header  |  1996-04-10  |  1KB  |  34 lines

  1. #include <SpeechRecognition.h>
  2. #include <AppleEvents.h>
  3.  
  4. pascal OSErr MyHandleSpeechDetected (AppleEvent *theAEevt, AppleEvent *reply, long refcon);
  5.  
  6.  
  7. pascal OSErr MyHandleSpeechDetected (AppleEvent *theAEevt, AppleEvent *reply, 
  8.                                                                     long refcon)
  9. {
  10.     OSErr                     myErr = noErr;
  11.     long                     actualSize;
  12.     DescType                 actualType;
  13.     OSErr                     recStatus = noErr;
  14.     SRRecognizer             myRec;
  15.  
  16.     /* Get the status and recognizer.                         */
  17.     myErr = AEGetParamPtr (theAEevt, keySRSpeechStatus, typeShortInteger,
  18.                 &actualType, (Ptr) &recStatus, sizeof (recStatus), &actualSize);
  19.     if (!myErr) myErr = recStatus;
  20.     if (!myErr) {
  21.         myErr = AEGetParamPtr (theAEevt, keySRRecognizer, typeSRRecognizer, 
  22.                         &actualType, (Ptr) &myRec, sizeof (myRec), &actualSize);
  23.         
  24.         if (!myErr) {
  25.             /* The user has started speaking. We can adjust the language model    */
  26.             /* to reflect the current context. Then we must call either         */
  27.             /* SRContinueRecognition or SRCancelRecognition.                    */ 
  28.             
  29.             myErr = SRContinueRecognition (myRec);
  30.         }
  31.     }
  32.  
  33.     return myErr;
  34. }